var v_list;
$(function(){
	v_list = new Vue({
		el: '#advice-index',
		data: {
			dto:{
				userId:'',
				mobile:'',
				address:''
			},
			theme:'',
			content:'',
		},
		methods: {
			getDto: function() {
				var time = new Date().getSeconds();
				console.log("jinlaile---")
				this.$http.get('../../common/getDto.do?time='+time, {
				}).then(function(res) {
					//接收后端传来的数据
					console.log(toJson(res.data));
					if(res.data.success){
						this.dto = res.data.data;
					}else{
						showRedMsg("message","用户信息获取失败!");
					}
				}, function(res) {
					console.log("获取用户信息出错:"+toJson(res));
				});
			},
			save: function() {
				if(this.theme==''){
					showRedMsg("message","请填写建议主题!");
					return false;
				} else if(this.theme.trim()==''){
					showRedMsg("message","请填写建议主题!");
					return false;
				}
				if(this.content==''){
					showRedMsg("message","请填写建议内容!");
					return false;
				} else if(this.content.trim()==''){
					showRedMsg("message","请填写建议内容!");
					return false;
				}
				this.$http.post('../../advice/save.do', {
					userId:this.dto.userId,
					theme:this.theme,
					content:this.content
				},{
					emulateJSON: true
				}).then(function(res) {
					//接收后端传来的数据
					console.log(toJson(res.data));
					if(res.data.success){
						window.location.href='advice-result.html';
					}else{
						showRedMsg("message","保存出错");
					}
				}, function(res) {
					showRedMsg("message","保存出错");
					console.log("保存出错:"+toJson(res));
				});
			}
		},
		ready: function() {
			//初始化获得总页面数和列表数据
			//$("#message-index").load('../s.html');
//			$("#left").load('../left.html');
			this.getDto();
		}
	});
});		